package com.mstore.dao;

import java.util.List;

import com.mstore.pojo.WeiXinMenu;
/**
 * 
 * 微信菜单
 *
 */
public class WeiXinMenuDao extends SuperDao {
	
	/**
	 * 
	 * 保存微信菜单
	 */
	public void saveMenu(WeiXinMenu weiXinMenu) {
		super.save(weiXinMenu);
	} 
	/**
	 * 
	 * 删除微信菜单
	 */
	public void delMenu(WeiXinMenu weiXinMenu) {
		/*String sql = "DELETE FROM weixin_menu WHERE ea_id = " + weiXinMenu.getEaId();
		super.executeUpdate(sql);*/
		
		StringBuilder sb = new StringBuilder();
		sb.append("DELETE FROM weixin_menu WHERE ea_id = ");
		sb.append(weiXinMenu.getEaId());

		super.executeUpdate(sb.toString());
	}
	/**
	 * 
	 * 查询企业下的微信菜单
	 */
	public List<Object> getWeiXinMenuByEaId(WeiXinMenu weiXinMenu) {
		String sql  = "from WeiXinMenu where eaId = ?";
		Object[] values = new Object[]{weiXinMenu.getEaId()};
		return super.getObject(sql, values);
	}
	/**
	 * 
	 * 查询企业微信菜单总数
	 */
	public Long getWeiXinMenuCount(WeiXinMenu weiXinMenu) {
		String sql  = "select count(wx) from WeiXinMenu wx where wx.eaId = ?";
		Object[] values = new Object[]{weiXinMenu.getEaId()};
		List<Object> list = super.getObject(sql, values);
		if (list == null) {
			return 0L;
		}
		return (Long)list.get(0);
	}
	
}
